import { computed } from 'vue';
import { EChartsOption } from 'echarts';
import { useAppStore } from '@/store';


interface optionsFn {
  (isDark: boolean): EChartsOption;
}
export default function useChartOption(sourceOption: optionsFn) {
  const appStore = useAppStore();
  const isDark = computed(() => {
    return appStore.theme === 'dark';
  });
  // echarts 配置文档 https://echarts.apache.org/zh/theme-builder.html
  // TODO echarts themes
  const chartOption = computed<EChartsOption>(() => {
    return sourceOption(isDark.value);
  });
  return {
    chartOption,
  };
}
